package com.darwin.eureka_client.entity.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    Integer stateCode;
    String msg;
    T data;
    List<T> dataList;

    public Result(T data) {
        this.data = data;
    }

    public Result(String msg,Integer stateCode) {
        this.msg = msg;
        this.stateCode=stateCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Result)) return false;
        Result<?> result = (Result<?>) o;
        return Objects.equals(getStateCode(), result.getStateCode()) &&
                Objects.equals(getMsg(), result.getMsg()) &&
                Objects.equals(getData(), result.getData()) &&
                Objects.equals(getDataList(), result.getDataList());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getStateCode());
    }
}
